<?php
require_once("../../libs/ValhallaKeys/SimpleORM/SimpleORM.php");
require_once("../../libs/ValhallaKeys/SimpleORM/1.0/ABModel.class.php");
require_once("../../libs/ValhallaKeys/SimpleORM/1.0/Model.class.php");

class User extends Model {
	
	public $id 			= array('type' => 'int', 'primary' => true);
	public $name 		= array('type' => 'string');
	public $id_statut 	= array('type' => 'int');
	
	public function __construct($param = null) {
		parent::__construct();
		
		$this->id = 0;
		$this->name = null;
		$this->id_statut = 0;
		
		$this->init($param);
	}
}

class Statut extends Model {
	
	public $id_statut 	= array('type' => 'int', 'primary' => true);
	public $name 		= array('type' => 'string');
	
	public function __construct($param = null) {
		parent::__construct();
		
		$this->id_statut = 0;
		$this->name = null;
		
		$this->init($param);
	}
}

echo "<pre>";

$r = new Model_Relation_OneClass(array(
	'from_classname' => 'User',
	'to_classname' => 'Statut'
));

echo $r->getJoin()."\n";
$r->getStatement(array('id' => 2));
$r->link(2, 3);
$r->unlink(2);
$r->unlink(2, 3);

$r = new Model_Relation_ManyClass(array(
	'from_classname' => 'User',
	'to_classname' => 'Statut'
));

$r = new Model_Relation_ManyClass(array(
	'from_classname' => 'User',
	'to_classname' => 'Statut',
	'join_table' => 'User_Statut'
));

$r->getStatement(array('id' => 2));
$r->link(2, 3);
$r->unlink(2);
$r->unlink(2, 3);

?>